package com.intellagric.controller.portal.traceability;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.module.traceability.ProduceBatchVo;
import com.intellagric.pojo.TraceProduceBatch;
import com.intellagric.service.traceability.trace_produce_batch.ProduceBatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/11/6
 * @DESC： 产品批次信息管理
 */
@Controller
public class ProduceBatchControler {

    @Autowired
    private ProduceBatchService produceBatchService;

    /**
     * 查询产品批次信息
     * @return TraceProduceBatch
     */
    @RequestMapping("/produce/batch/{id}")
    @ResponseBody
    public TraceProduceBatch get(@PathVariable String id) {
        return produceBatchService.getProduceBatchById(id);
    }
    
    /**
     * 查询产品批次信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/produce/batch/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return produceBatchService.getProduceBatchList();
    }

    /**
     * 根据批次号进行产品的溯源，查询产品批次信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/produce/trace/list")
    @ResponseBody
    public LayuiDataGridResult getTraceList(int page ,int limit,ProduceBatchVo produceBatchVo) {
        return produceBatchService.getProduceBatchListWithRelation(page, limit, produceBatchVo);
    }
    
    /**
     * 分页查询产品批次信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/produce/batch/page")
    @ResponseBody
    public LayuiDataGridResult getPage(int page ,int limit) {
        return produceBatchService.getProduceBatchPage(page,limit);
    }

    /**
     * 根据VO实体类查询产品批次信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/produce/batch/query")
    @ResponseBody
    public LayuiDataGridResult getByVo(int page ,int limit,ProduceBatchVo produceBatchVo) {
        return produceBatchService.getProduceBatchByVo(page, limit, produceBatchVo);
    }
}
